package com.common.enums;

/**
 * @className: MAV_STATE
 * @description: MAV state enumeration for flight control system
 * @author: Li Chuanwei
 * @date: 2024/07/04 1:14
 * @Company: Copyright [日期] by [作者或个人]
 **/
public enum MAV_STATE {
    MAV_STATE_UNINIT(0, "未知"),
    MAV_STATE_BOOT(1, "正在启动"),
    MAV_STATE_CALIBRATING(2, "校准中"),
    MAV_STATE_STANDBY(3, "未解锁"),
    MAV_STATE_ACTIVE(4, "解锁"),
    MAV_STATE_CRITICAL(5, "非正常"),
    MAV_STATE_EMERGENCY(6, "紧急"),
    MAV_STATE_POWEROFF(7, "关机"),
    MAV_STATE_FLIGHT_TERMINATION(8, "终止飞行"),
    MAV_STATE_ENUM_END(9, ""); // Empty description for ENUM_END

    private final int value;
    private final String description;

    MAV_STATE(int value, String description) {
        this.value = value;
        this.description = description;
    }

    /**
     * Get the integer value associated with the MAV_STATE.
     *
     * @return The integer value of the MAV_STATE.
     */
    public int getValue() {
        return value;
    }

    /**
     * Get the description of the MAV_STATE.
     *
     * @return The description of the MAV_STATE.
     */
    public String getDescription() {
        return description;
    }

    /**
     * Get the MAV_STATE enum constant from its integer value.
     *
     * @param value The integer value of the MAV_STATE.
     * @return The MAV_STATE enum constant, or null if not found.
     */
    public static MAV_STATE fromValue(int value) {
        for (MAV_STATE state : MAV_STATE.values()) {
            if (state.getValue() == value) {
                return state;
            }
        }
        return null; // or throw an IllegalArgumentException if preferred
    }

    /**
     * Override toString() to return the description of the MAV_STATE.
     *
     * @return The description of the MAV_STATE.
     */
    @Override
    public String toString() {
        return description;
    }
}
